package VacationHomework.LeetCode;

public class NewCoderDelete {
    public ListNode deleteDuplication(ListNode pHead) {
        if(pHead==null || pHead.next==null){
            return pHead;
        }
        ListNode dummyHead=new ListNode(-1);
        dummyHead.next=pHead;
        ListNode pre=dummyHead;
        ListNode cur=pre.next;
        while (cur!=null){
            if(cur.next!=null && cur.val==cur.next.val){
                while (cur.next!=null && cur.val==cur.next.val) {
                    cur = cur.next;
                }
                cur=cur.next;
                pre.next=cur;
            }else {
                pre=cur;
                cur=cur.next;
            }
        }
        return dummyHead.next;
}
}
